import camera from '@/three/Camera'
import renderer from "@/three/renderer"
// 监听屏幕大小改变的变化，设置渲染的尺寸
window.addEventListener("resize", () => {
    //   console.log("resize");
    // 更新摄像头
    camera.aspect = window.innerWidth / window.innerHeight;
    //   更新摄像机的投影矩阵
    camera.updateProjectionMatrix();
  
    //   更新渲染器
    renderer.setSize(window.innerWidth, window.innerHeight);
    //   设置渲染器的像素比例
    renderer.setPixelRatio(window.devicePixelRatio);
  });
  // 设置双击显示全屏效果
window.addEventListener("dblclick", () => {
  // 判断现在是否是全屏
  // 判断是否有全屏对象
  const fullscreenElement =
      document.fullscreenElement || document.webkitFullscreenElement;
  if (!fullscreenElement) {
      // console.log(renderer.domElement);
      // 使用canvas对象请求全屏
      if (renderer.domElement.requestFullscreen) {
          renderer.domElement.requestFullscreen();
      } else if (renderer.domElement.webkitRequestFullscreen) {
          renderer.domElement.webkitRequestFullscreen();
      }
  } else {
      //   使用document对象取消全屏
      if (document.exitFullscreen) {
          document.exitFullscreen();
      } else if (document.webkitExitFullscreen) {
          document.webkitExitFullscreen();
      }
  }
});